import java.util.Set;
import java.util.TreeMap;

public class TreeMapTest {
    public static void main(String[] args) {
        TreeMap<Users,String> treeMap=new TreeMap<>();
        Users u=new Users("oldlu",18);
        Users u1=new Users("admin",22);
        Users u2=new Users("sxt",22);
        treeMap.put(u,"oldlu");
        treeMap.put(u1,"admin");
        treeMap.put(u2,"sxt");
        Set<Users> keys = treeMap.keySet();
        for(Users user:keys){
            String value = treeMap.get(user);
            System.out.println(user+"-----"+value);
        }

        System.out.println("-----------");
        TreeMap<Student,String> treeMap1=new TreeMap<>(new StudentComparator());
        Student stu1=new Student("oldlu",18);
        Student stu2=new Student("sxt",22);
        Student stu3=new Student("admin",22);
        treeMap1.put(stu1,"oldlu");
        treeMap1.put(stu2,"sxt");
        treeMap1.put(stu3,"admin");
        Set<Student> keys1= treeMap1.keySet();
        for(Student key:keys1){
            System.out.println(key+"---------"+treeMap1.get(key));
        }
    }
}
